import mockApi from "@/api/mockApi";
import type {PositionForm} from '@/types/req/positionForm'
import type {PositionQueryForm} from '@/types/req/positionQueryForm'
import type {Position} from '@/types/resp/position'
import type {Response} from '@/types/response'
import type {Result} from '@/types/result'
import type {Page} from "@/types/page";

export default class positionApi {
  static positions: Position[] = [
    {"id":1,"enterpriseId":4,"enterpriseName":"绿源农业有限公司","positionName":"市场经理","responsibilities":"负责市场调研、品牌推广及销售策略制定，带领团队完成销售目标","createTime":"2024-07-29 22:21:10","modifyTime":"2024-06-20 22:21:10"},
    {"id":2,"enterpriseId":2,"enterpriseName":"蓝天环保有限公司","positionName":"环境工程师","responsibilities":"负责环保项目的设计、实施及技术支持，确保项目符合环保标准","createTime":"2024-06-07 22:21:10","modifyTime":"2024-05-14 22:21:10"},
    {"id":3,"enterpriseId":1,"enterpriseName":"阳光科技有限公司","positionName":"软件开发工程师","responsibilities":"负责软件系统的设计、开发及维护，编写高质量代码并解决技术问题","createTime":"2024-04-06 22:21:10","modifyTime":"2024-12-06 22:21:10"},
    {"id":4,"enterpriseId":3,"enterpriseName":"星辰教育集团","positionName":"课程顾问","responsibilities":"负责课程推广、客户咨询及销售，协助客户选择适合的课程","createTime":"2024-12-03 22:21:10","modifyTime":"2024-04-11 22:21:10"},
    {"id":5,"enterpriseId":4,"enterpriseName":"绿源农业有限公司","positionName":"供应链专员","responsibilities":"负责供应商管理、采购协调及物流跟踪，确保供应链高效运作","createTime":"2024-05-03 22:21:10","modifyTime":"2024-09-09 22:21:10"},
    {"id":6,"enterpriseId":2,"enterpriseName":"蓝天环保有限公司","positionName":"项目经理","responsibilities":"负责环保项目的整体规划、执行及交付，协调团队资源并确保项目按时完成","createTime":"2024-03-25 22:21:10","modifyTime":"2025-01-05 22:21:10"},
    {"id":7,"enterpriseId":4,"enterpriseName":"绿源农业有限公司","positionName":"财务分析师","responsibilities":"负责财务数据分析、预算编制及成本控制，提供决策支持","createTime":"2024-05-07 22:21:10","modifyTime":"2024-02-21 22:21:10"}
  ]

  static async save (positionForm: PositionForm): Promise<Result<void>> {
    console.log('positionApi save params', positionForm)
    const response: Response<void> = await mockApi.operateSuccessfully()
    return response.data
  }

  static async find (positionQueryForm: PositionQueryForm): Promise<Result<Page<Position>>> {
    console.log('positionApi find params', positionQueryForm)
    const response: Response<Page<object>> = await mockApi.queryPageSuccessfully(positionApi.positions)
    return response.data
  }

  static async findById (id: number): Promise<Result<Position>> {
    console.log('positionApi findById id', id)
    let target = {}
    for (const a of positionApi.positions) {
      if (a.id === id) {
        target = a
      }
    }
    const response: Response<Position> = await mockApi.operateSuccessfullyWithData(target)
    return response.data
  }

  static async del (id: number): Promise<Result<void>> {
    console.log('positionApi del id', id)
    const response: Response<void> = await mockApi.operateSuccessfully()
    return response.data
  }
}
